
package Gr;
import java.sql.*;

public class conexion {
   

static String bd = "Hotel"; 
   static String login = "luis"; 
   static String password = "luis"; 
   static String url = "jdbc:derby://localhost:1527/"+bd; 

   
   
public Statement conectar() {
Connection conn = null;
Statement st=null;
try {
Class.forName("org.apache.derby.jdbc.ClientDriver");
conn = DriverManager.getConnection(url, login, password);
if (conn != null)
{
 System.out.println("Yeah, hemos conectado con  "+url+" ... Ok");
 st=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);

//conn.close();
}
}
catch(SQLException ex) {
System.out.println("Rayos!!! Hubo un problema al conectar con la base "+url);
}
catch(ClassNotFoundException ex) {
System.out.println(ex);
}
 return st;
}
}

